jQuery(document).ready(function(){
	window.status = "Jquery loaded";
	
	jQuery("#twitter ul a").live("click", function() { 
			jQuery(this).attr("target","_blank");
		});
	
	jQuery("a[rel='external']").each( function(i) { 
		jQuery(this).attr("target","_blank");
	});
	
	$.nyroModalSettings({
			debug: false,
			//closeButton: null,
			endShowContent: initTabs
	});
	
	initTabs();
	
	/* Workout templates update */
	//jQuery("#workout-form #WorkoutTemplateId").change(onTemplateChange); 
	
});

function initTabs() {
	var tabContainers = jQuery('div.tab');
	var tabs = jQuery('a.tab-link');

		tabs.each( function(i) { 
		  jQuery(this).click(function() { 
			tabContainers.hide().filter(this.hash).show();
			var parent = jQuery(this).get(0);
			jQuery(parent).siblings().removeClass("active");
			jQuery(parent).addClass("active");
			return false;
		  }); 
		 });
		tabs.eq(0).click();
}


function onTemplateChange(){
	var selected = jQuery(this + 'option:selected');
	var output = "";
	if(selected.val() != 0){
		output = "You Selected " + selected.val();
	}
	jQuery("#output").html(output);
	alert(output);
}